/*
 * ECARX Technology Limited is the owner of the copyright and the trade secret of this software.
 * Without permission, no one has the right to obtain, disclose or use this software in any way.
 */
package com.ecarx.systemui.plugin.ui.navigationbar

import android.content.Context
import android.util.AttributeSet
import android.view.Gravity
import android.widget.LinearLayout


enum class NavigationBarItem {
    HOME,
    APP_PANEL,
    SETTING,
    SEAT_ADJUST_PANEL,
    HVAC_TEMP,
    HVAC_FAN,
    MAP_NAVI,
    MULTI_MEDIA,
    AVM360,
    ENERGY,
    VOLUME,


}

class NavigationBarView : LinearLayout {

    /**
     * just modify the order in this map to adapt to different project UX requirements
     */
    private var navigationButtonsOrderMap = linkedMapOf(
        NavigationBarItem.HOME to HomeButton(context),
        NavigationBarItem.APP_PANEL to AppPanelButton(context),
        NavigationBarItem.SETTING to SettingsButton(context),
        NavigationBarItem.SEAT_ADJUST_PANEL to SeatAdjustPanelButton(context),
        NavigationBarItem.HVAC_TEMP to HvacTempView(context),
        NavigationBarItem.HVAC_FAN to HvacFanSpeedView(context),
        NavigationBarItem.MAP_NAVI to NavigationButton(context),
        NavigationBarItem.MULTI_MEDIA to MultiMediaButton(context),
        NavigationBarItem.AVM360 to Avm360Button(context),
        NavigationBarItem.ENERGY to EnergyButton(context),
        NavigationBarItem.VOLUME to VolumeButton(context),

        )

    constructor(context: Context?) : this(context!!, null) {}
    constructor(context: Context?, attrs: AttributeSet?) : this(context!!, attrs, 0) {}
    constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(
        context!!,
        attrs,
        defStyleAttr
    ) {
        init()
    }

    fun init() {
        layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)

        val params = LayoutParams(80, 80)
        params.weight = 1.0f
        params.gravity = Gravity.CENTER_VERTICAL

        for (button in navigationButtonsOrderMap) {
            when (button.key) {
                NavigationBarItem.HVAC_TEMP -> {
                    params.apply {
                        width = 342
                        height = 80
                    }
                }
                else -> {
                    params.apply {
                        width = 80
                        height = 80
                    }
                }
            }
            addView(button.value, params)
        }
    }

}
